package com.yochi.pictureseditor.effects.effectsimpl;

import com.yochi.pictureseditor.effects.Effect;
import com.yochi.pictureseditor.exceptions.NullImageException;
import com.yochi.pictureseditor.images.Image;
import com.yochi.pictureseditor.images.ImageImpl;

public class EffectSepia extends Effect {
	
	  //////////////////
	 // CONSTRUCTORS //
	//////////////////
	
	public EffectSepia(Image img) {
		super(img);
	}
	
	
	  ////////////
	 // NATIVE //
	////////////
	
	static {
		System.loadLibrary("pictureseditor");
	}
	
	public native ImageImpl process(Image image);
	
	
	  ////////////
	 // PUBLIC //
	////////////
	
	@Override
	public Image apply() throws NullImageException {
		if(getImage()==null) throw new NullImageException("load an image before applying effect");
		ImageImpl result = process(getImage());
		setResult(result);
		return result;
	}
	
	@Override
	public String toString() {
		return "[EffectSepia]";
	}

}
